package com.kugou.miniapp.dao;

import com.kugou.miniapp.domain.Music;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Mapper
public interface MusicMapper {


    @Select("select music_id from his_music where user_id = #{user_id} order by date desc")
    public List<String> getHisMusicByUserId(String user_id);

    @Select("select music_id from like_music where user_id = #{user_id}")
    public List<String> getLikeByUserId(String user_id);

    @Update("update his_music set date = #{date} where music_id = #{music_id} and user_id = #{user_id}")
    public int updateHisMusic(Music music);

    @Select("select * from his_music where music_id = #{music_id} and user_id = #{user_id}")
    public Music getHisMusicByMIdAndUId(Music music);

    @Insert("insert into like_music (music_id, user_id) values (#{music_id}, #{user_id})")
    public int insertLikeMusic(Music music);

    @Insert("insert into his_music (music_id, user_id, date, music_name) values(#{music_id}, #{user_id},  #{date}, #{music_name})")
    public int insertHisMusic(Music music);

    @Select("select music_id, id, userid from music_list where userid = #{userid}")
    public List<Music> getMusicsByUserId(String userid);

    @Select("select music_id,user_id,id  from like_music where user_id = #{user_id}")
    public List<Music> getLikeMusicByUserId(String user_id);

    @Delete("delete from like_music where user_id = #{user_id} and music_id = #{music_id}")
    public int delLikeMusicByUserIdAndMusicId(Map<String, Object> condition);

    @Delete("delete from his_music where user_id = #{user_id} and music_id = #{music_id}")
    int delHisMusicByUserIdAndMusicId(Map<String, Object> condition);
}
